package com.whs.demo.assets;

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;

public class Assets {

    private static final String testAtlasFile =  "pic/test.pack";
    private static final String chFile = "pic/ch.fnt";
    private static AssetManager manager;
    public static BitmapFont font ;
    public static TextureAtlas testAtlas;

    public static void init() {
        if (manager == null) {
            manager = new AssetManager();
        }
    }

    public static void loadAll() {
        loadAtlas(testAtlasFile);
        manager.load(chFile, BitmapFont.class);
        
        
    }
    public static void initTestAtlas(){
        testAtlas = getTextAtlas(testAtlasFile);
        font = manager.get(chFile, BitmapFont.class);
    }
    
    

    public static void loadAtlas(String fileName) {
        manager.load(fileName, TextureAtlas.class);

    }

    public static TextureAtlas getTextAtlas(String filename) {
        return manager.get(filename, TextureAtlas.class);
    }
    
    public static void dispose(){
        
        if(testAtlas != null){
            testAtlas.dispose();
        }
        if(font != null){
            font.dispose();
        }
        manager.dispose();
    }
    
    public static void finishLoading(){
         manager.finishLoading();
    }

}
